package com.entrogy.dao;

import com.entrogy.bean.*;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @ClassName SalarySlipMapper
 * @Description
 * @Author luoxingjiang
 * @Date 2019/8/27 0027 下午 3:04
 * @Version 1.0
 **/
@Repository
public interface SalarySlipMapper {

    /**
     * 插入工资条模板数据
     * @param salarySlipTemplate
     * @return
     */
    int insertSalarySlipTemplate(SalarySlipTemplateEntity salarySlipTemplate);

    /**
     * 插入某条工资条模板
     * @param salaryTypeName
     * @param salarySlipTemplateId
     * @return
     */
    int insertSalarySlipTemplateData(@Param(value = "salaryTypeName") String salaryTypeName, @Param(value = "salarySlipTemplateId") Integer salarySlipTemplateId);

    /**
     * 更新工资条模板信息
     * @param salarySlipTemplate
     * @return
     */
    int updateSalarySlipTemplate(SalarySlipTemplateEntity salarySlipTemplate);

    /**
     * 删除工资条的组成信息
     * @param salarySlipTemplateId
     * @return
     */
    int deleteSalaryTemplateCompose(Integer salarySlipTemplateId);

    /**
     * 根据模板id查询模板信息以及工资组成
     * @param templateId
     * @param enableStatus
     * @return
     */
    List<SalarySlipTemplateEntity> listSalarySlipTemplate(@Param("templateId") Integer templateId, @Param("enableStatus") Integer enableStatus);

    /**
     * 插入教师工资条初始数据
     * @param userId
     * @param salaryComposeList
     * @param salaryTeacherInformationId
     * @return
     */
    int insertTeacherSalary(@Param(value = "userId") String userId, @Param(value = "salaryComposeList") List<SalaryComposeEntity> salaryComposeList, @Param(value = "salaryTeacherInformationId") Integer salaryTeacherInformationId);

    /**
     * 插入教师某月工资条状态数据
     * @param salaryTeacherInfoEntity
     * @return
     */
    int insertSalaryInformation(SalaryTeacherInfoEntity salaryTeacherInfoEntity);

    /**
     * 查询教师工资组成数据
     * @param salaryInfoId
     * @param schoolCode
     * @return
     */
    List<SalaryTeacherInfoEntity> listTeacherSalaryInfo(@Param(value = "salaryYear") Integer salaryYear, @Param(value = "salaryMonth") Integer salaryMonth, @Param(value = "salaryInfoId") Integer salaryInfoId, @Param(value = "schoolCode") Integer schoolCode);

    /**
     * 查询教师某种状态的工资条的基本信息
     * @param salaryYear
     * @param salaryMonth
     * @param teacherId
     * @param send
     * @param readStatus
     * @param confirmStatus
     * @param recallStatus
     * @return
     */
    List<SalaryTeacherInfoEntity> ListTeacherSalarySlipId(@Param(value = "salaryYear") Integer salaryYear, @Param(value = "salaryMonth") Integer salaryMonth, @Param(value = "teacherId") String teacherId, @Param(value = "send") Integer send, @Param(value = "readStatus") Integer readStatus, @Param(value = "confirmStatus") Integer confirmStatus, @Param(value = "recallStatus") Integer recallStatus);

    /**
     * 删除教师工资信息
     * @param salaryTeacherInformationId
     * @return
     */
    int deleteTeacherSalaryDetail(Integer salaryTeacherInformationId);

    /**
     * 插入工资信息
     * @param salaryTeacherDetail
     * @return
     */
    int insertTeacherSalaryDetail(SalaryTeacherDetailEntity salaryTeacherDetail);

    /**
     * 删除教师工资条信息
     * @param salaryTeacherInformationId
     * @return
     */
    int deleteTeacherSalaryInfo(Integer salaryTeacherInformationId);

    /**
     * 根据schoolCode查找工资模板id，暂时一个学校只能有一个工资模板id
     * @param schoolCode
     * @return
     */
    Integer getSalarySlipTemplateIdBySchoolCode(Integer schoolCode);

    /**
     * 查询出教师的工资条状态信息（如果是查看自己的工资条的话，那么只能看到已发送的）
     * @param schoolCode
     * @param salaryYear
     * @param salaryMonth
     * @param userId
     * @return
     */
    List<SalaryTeacherInfoEntity> listTeacherSalarySlipInfo(@Param(value = "schoolCode") Integer schoolCode, @Param(value = "salaryYear") Integer salaryYear, @Param(value = "salaryMonth") Integer salaryMonth, @Param(value = "userId") String userId);

    /**
     * 查看该学校有哪些月份的工资条
     * @param schoolCode
     * @return
     */
    List<MonthSalaryStatusEntity> listMonthSalary(Integer schoolCode);

    /**
     * 查询某月工资条总数
     * @param salaryYear
     * @param salaryMonth
     * @param schoolCode
     * @return
     */
    Integer countTotalSalarySlip(@Param(value = "salaryYear") Integer salaryYear, @Param(value = "salaryMonth") Integer salaryMonth, @Param(value = "schoolCode") Integer schoolCode);

    /**
     * 查询某月工资条未读条数
     * @param salaryYear
     * @param salaryMonth
     * @param schoolCode
     * @return
     */
    Integer countHasNotRead(@Param(value = "salaryYear") Integer salaryYear, @Param(value = "salaryMonth") Integer salaryMonth, @Param(value = "schoolCode") Integer schoolCode);

    /**
     * 查询某月工资条未发送条数
     * @param salaryYear
     * @param salaryMonth
     * @param schoolCode
     * @return
     */
    Integer countHasNotSend(@Param(value = "salaryYear") Integer salaryYear, @Param(value = "salaryMonth") Integer salaryMonth, @Param(value = "schoolCode") Integer schoolCode);

    /**
     * 查询某月工资条未确认条数
     * @param salaryYear
     * @param salaryMonth
     * @param schoolCode
     * @return
     */
    Integer countHasNotConfirm(@Param(value = "salaryYear") Integer salaryYear, @Param(value = "salaryMonth") Integer salaryMonth, @Param(value = "schoolCode") Integer schoolCode);

    /**
     * 更新某一条工资条状态
     * @param send
     * @param readStatus
     * @param confirmStatus
     * @param recallStatus
     * @param salaryInfoId
     * @return
     */
    int updateSalaryInfoStatus(@Param(value = "send") Integer send, @Param(value = "readStatus") Integer readStatus, @Param(value = "confirmStatus") Integer confirmStatus, @Param(value = "recallStatus") Integer recallStatus, @Param(value = "salaryInfoId") Integer salaryInfoId);

    /**
     * 查询工资条条数
     * @param schoolCode
     * @param salaryYear
     * @param salaryMonth
     * @param userId
     * @return
     */
    Integer countTeacherSalarySlip(@Param(value = "schoolCode") Integer schoolCode, @Param(value = "salaryYear") Integer salaryYear, @Param(value = "salaryMonth") Integer salaryMonth, @Param(value = "userId") String userId);

    /**
     * 根据工资条id查询这些教师的电话号码
     * @param salaryInfoIdList
     * @return
     */
    List<String> listPhoneBySalaryInfoId(@Param("salaryInfoIdList") List<Integer> salaryInfoIdList);

    /**
     * 更新教师的工资信息
     * @param salaryDetailId
     * @param salary
     * @return
     */
    int updateSalaryDetail(@Param(value = "salaryDetailId") Integer salaryDetailId, @Param(value = "salary") Double salary);

    /**
     * 修改工资条组成时，只能将原来的哪些工资条组成状态修改未启用
     * @param enable
     * @param enable
     * @return
     */
    int updateSalaryTemplateCompose(@Param("salarySlipTemplateId") Integer salarySlipTemplateId, @Param(value = "enable") int enable);

    /**
     * 某个学校月份工资条数量
     * @param schoolCode
     * @return
     */
    Integer countMonthSalary(@Param("schoolCode") Integer schoolCode);

    /**
     * 批量插入教师工资条数据
     * @param salaryTeacherDetailList
     * @return
     */
    int insertBatchSalary(@Param("salaryTeacherDetailList") List<SalaryTeacherDetailEntity> salaryTeacherDetailList);

    /**
     * 一键发送该月的所有工资条
     * @param salaryYear
     * @param salaryMonth
     * @param schoolCode
     * @return
     */
    List<Integer> listMonthSalaryInfoId(@Param("salaryYear") Integer salaryYear, @Param("salaryMonth") Integer salaryMonth, @Param("schoolCode") Integer schoolCode);
}
